<script type="text/javascript">
function changeStatus(obj,index){
   document.getElementById("txtNofaktur_" + index).disabled = ! obj.checked;
   document.getElementById("txtDatefaktur_" + index).disabled = ! obj.checked;
   document.getElementById("txtNokwitansi_" + index).disabled = ! obj.checked;
   document.getElementById("txtcustomer_" + index).disabled = ! obj.checked;
   document.getElementById("txtProductname_" + index).disabled = ! obj.checked;
   document.getElementById("txthrgbrg_" + index).disabled = ! obj.checked;
   document.getElementById("txtQuantity_" + index).disabled = ! obj.checked;
   document.getElementById("txtDiscount_" + index).disabled = ! obj.checked;
   document.getElementById("txtAmount_" + index).disabled = ! obj.checked;
   document.getElementById("kdeiddetail_" + index).disabled = ! obj.checked;
}
</script>
<form method="post" name="frmSearch" action="<?php echo site_url('returpenjualancontroller');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
        <tr>
            <td width="74"><strong>NO Faktur</strong></td>
            <td width="11" align="center"><strong>:</strong></td>
            <td colspan="3">
            	<input type="text"  name="fakturkode" id="fakturkode" maxlength="12" size="25" >
            </td>
		</tr>
        <tr align="center">
        	<td colspan="5" height="25"><input type="submit" name="btnview" id="btnview" value="Search"></td>
    	</tr>
    </table>
</form>
<br />
<div class="cleaner_h10"></div>
<form method="post" name="frmsave" action="<?php echo site_url('returpenjualancontroller/simpanretur');?>">
<table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
	<tr>
        <td colspan="2"><strong>Keterangan</strong></td>
        <td colspan="9" ><input type="text"  name="keterangan" id="keterangan" size="75" maxlength="100" /></td>
    </tr>
    <tr>
        <td colspan="12">&nbsp;</td>
    </tr>
    <tr style="background-color:#FFF; color:#000000;" align="center">
        <td colspan="10" height="25"><strong>LIST Retur Penjualan</strong></td>
    </tr>
    <tr style="background-color:#333; color:#FFF;" align="center">
    	<td width="74">&nbsp;</td>
    	<td width="90">No Faktur</td>
        <td width="92">Tanggal Faktur</td>
    	<td width="77">No Kwitansi</td>
        <td width="125">Nama Customer</td>
        <td width="144">Nama Barang</td>
        <td width="144">Harga Barang</td>
        <td width="59">Quantity</td>
        <td width="61">Discount</td>
        <td width="89">Jumlah Harga</td>
    </tr>
	<tbody id="datareturjual"><?php
		$i = 0; 
		if(count($transreturjual)>0){
			foreach($transreturjual as $treturjual){
				$style = "";
				if($i%2 == 0)$style="cellDefault"; else $style="cellAlternate";
	            echo "<tr class=\"".$style."\">";
	            echo "	<td><input type=\"checkbox\" name=\"chkitem[]\" id=\"chkitem[]\" value=\"".$treturjual->KodeDetailBarang."\" onclick=\"javascript:changeStatus(this,".$i.")\" /></td>";
	            echo "  <td><input id=\"txtNofaktur_".$i."\" name=\"txtNofaktur[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" size=\"100\" maxlength=\"50\" value=\"".$treturjual->NoFaktur."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
	            echo "  <td><input id=\"txtDatefaktur_".$i."\" name=\"txtDatefaktur[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" size=\"50\" maxlength=\"50\" value=\"".$treturjual->DateFaktur."\" readonly=\"readonly\" disabled=\"disabled\" /></td>";
	            echo "  <td><input id=\"txtNokwitansi_".$i."\" name=\"txtNokwitansi[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:left;\" size=\"100\" maxlength=\"30\" value=\"".$treturjual->NoKwitansi."\" readonly=\"readonly\" disabled=\"disabled\" /></td>";
	            echo "  <td><input id=\"txtcustomer_".$i."\" name=\"txtcustomer[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:left;\" size=\"100\" maxlength=\"50\" value=\"".$treturjual->namapelanggan."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
	            echo "  <td><input id=\"txtProductname_".$i."\" name=\"txtProductname[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:left;\" size=\"100\" maxlength=\"50\" value=\"".$treturjual->Productname."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
				echo "  <td><input id=\"txthrgbrg_".$i."\" name=\"txthrgbrg[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" value=\"".$treturjual->HargaBarang."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
	            echo "  <td><input id=\"txtQuantity_".$i."\" name=\"txtQuantity[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" value=\"".$treturjual->quantity."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
	            echo "  <td><input id=\"txtDiscount_".$i."\" name=\"txtDiscount[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" value=\"".$treturjual->discount."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";
				$qty = 0;
				$harga = 0;
				$qty = intval($treturjual->quantity);
				$harga = intval($treturjual->HargaBarang);
				$total = 0;
				if(intval($treturjual->discount) != 0){
					$total = ($qty * $harga) - ((intval($disc) * ($qty * $harga))/100);
				}else{
					$total = $qty * $harga;
				}
	            echo "  <td><input id=\"txtAmount_".$i."\" name=\"txtAmount[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:right;\" value=\"".$total."\" readonly=\"readonly\" disabled=\"disabled\"/></td>";	                
				//echo "	<input type=\"hidden\"  name=\"kdeiddetail[]\" id=\"kdeiddetail_".$i."\" size=\"30\" maxlength=\"25\" value=\"".$treturjual->KodeDetailBarang."\" disabled=\"disabled\" />";
				echo "	<input type=\"hidden\"  name=\"kdsupp[]\" id=\"kdsupp_".$i."\" size=\"30\" maxlength=\"25\" value=\"".$treturjual->KodeSupplier."\" />";
	            echo "</tr>";
	            $i++;
			}?>
        	
    <?php } else{
            echo "<tr>";
            echo "<td colspan='10' style='text-align:center;color:red;'>No Data To Display</td>";
            echo "</tr>";
    } ?></tbody>
    <tr class="cellDefault">
        <td colspan="10" align="center"><input type="submit" name="btnsave" value="Save"> &nbsp;|&nbsp; <input type="submit" name="btnback" value="Back" onclick="javascript:window.location='<?php echo site_url('menuhomecontroller'); ?>';"></td>
    </tr>
    <?php if(!empty($message))?>{message}
</table>
<?php //echo $links;?>
<div id="transdelay" class="holder"></div>
</form>